#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    string trans(string s, int n)
    {
        int start = 0, last = 0;
        for (int i = 0; i < s.size(); ++i)
        {
            if (isspace(s[i]))
            {
                reverse(s.begin() + start, s.begin() + i);
                start = i + 1;
                continue;
            }
            else
            {
                if (islower(s[i]))
                {
                    s[i] = s[i] - 'a' + 'A';
                }
                else
                {
                    s[i] = s[i] - 'A' + 'a';
                }
            }
        }
        reverse(s.begin() + start, s.end());
        reverse(s.begin(), s.end());
        return s;
    }
};